@extends('layouts.app')
@section('title',$topic->title)
@section('desc',$topic->desc)

@section('content')
    <div class="row">
        <div class="col-md-3">
            <div class="card d-none d-md-block">
                <div class="card-header bg-transparent">
                    <h5 class="text-center text-muted pt-2">作者 ：<span
                            style="color:deeppink;">{{$topic->user->name}}</span></h5>
                </div>
                <div class="card-body">
                    <a href="{{route('users.show',$topic->user->id)}}">
                        @include('shared._avatar',['avatar'=>$topic->user->avatar,'is_border'=>'hidden'])


                    </a>
                </div>
            </div>
        </div>
        <div class="col-md-9">
            <div class="card">
                <div class="card-body">
                    <h5 class="text-primary text-center">{{$topic->title}}</h5>
                    <small class="text-secondary d-flex justify-content-center align-items-center">
                        <i class="fa-regular fa-user"></i>&nbsp;
                        <a class="text-decoration-none text-secondary"
                           href="{{route('users.show',$topic->user->id)}}">
                            {{$topic->user->name}}
                        </a>
                        <span>
                            &nbsp;&nbsp;•&nbsp;&nbsp;
                        </span>
                        <i class="fa-regular fa-comment-dots"></i>&nbsp;
                        {{$topic->reply_count}}
                        <span>
                            &nbsp;&nbsp;•&nbsp;&nbsp;
                        </span>
                        <i class="fa-regular fa-folder-closed"></i>&nbsp;
                        <a class="text-decoration-none text-secondary"
                           href="{{route('categories.show',$topic->category->id)}}">
                            {{$topic->category->name}}
                        </a>
                        <span>
                          &nbsp;  &nbsp;•&nbsp;&nbsp;
                        </span>
                        <i class="fa-regular fa-clock"></i>&nbsp;
                        {{$topic->created_at->diffForHumans()}}
                    </small>
                    <div class="d-flex justify-content-center mt-2">
                        <a href="{{route('topics.create')}}" class="btn btn-sm btn-outline-success">
                            <i class="fa-solid fa-circle-plus"></i>
                            发帖
                        </a>
                        @can('update',$topic)
                            <a href="{{route('topics.edit',$topic->id)}}" class="btn btn-sm btn-outline-primary mx-3">
                                <i class="fa-solid fa-circle-plus"></i>
                                编辑
                            </a>
                            <form action="{{route('topics.destroy',$topic->id)}}" method="POST"
                            onsubmit="return confirm('您是否真的要删除?')"
                            >
                                @csrf
                                {{method_field('DELETE')}}
                                <button type="submit" class="btn btn-sm btn-outline-danger">
                                    <i class="fa-solid fa-trash-can"></i>
                                    删除
                                </button>
                            </form>

                        @endcan
                    </div>
                    <div class="topic-body mt-4">
                        {!! $topic->content !!}
                    </div>
                </div>
            </div>
            @includeWhen(Auth::check(),'topics._reply_create',['topic'=>$topic])
            <div class="card mt-2">
                @include('topics._reply_list',['replies'=>$topic->replies()->with('user')->recent()->get()])
            </div>
        </div>
    </div>
@stop
